package Services;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;

public class RegisterService {

	public int sendRegistrationRequest(String username, String password, String email, String fname, String lname) {
		DBConnection connection = new DBConnection();
		CallableStatement cs = null;
		ResultSet rs = null;
		Connection con = null;
		int returncode = 0;
		
		try {
			con = connection.getConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}

		try {
			cs = con.prepareCall("{call REGISTRATIONREQUEST(?,?,?,?,?)}");
			cs.setString(1, username);
			cs.setString(2, password);
			cs.setString(3, email);
			cs.setString(4, fname);
			cs.setString(5, lname);
			rs = cs.executeQuery();

			while (rs.next()) {
				returncode = rs.getInt("returncode");
			}
			cs.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println(returncode);
		return returncode;
	}

}
